home *** CD-ROM | disk | FTP | other *** search
/ TOS Silver 2000 / TOS Silver 2000.iso / programm / GNU_C++ / LIB / MTLB49CF.LZH / include / stdarg.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-05-29  |  1.7 KB  |  71 lines

  1. /*
  2.  * STDARG.H
  3.  */
  4.  
  5. #ifndef _STDARG_H
  6. #ifndef va_start    /* in case of varargs being included */
  7. #define    _STDARG_H
  8.  
  9. #ifndef _COMPILER_H
  10. #include <compiler.h>
  11. #endif
  12.  
  13. #ifdef __GNUC__
  14.  
  15. /* Define __gnuc_va_list.  */
  16.  
  17. #ifndef __GNUC_VA_LIST
  18. #define __GNUC_VA_LIST
  19. typedef void *__gnuc_va_list;
  20. #endif
  21.  
  22. /* Amount of space required in an argument list for an arg of type TYPE.
  23.    TYPE may alternatively be an expression whose type is used.  */
  24.  
  25. #define __va_rounded_size(TYPE)  \
  26.   (((sizeof (TYPE) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))
  27.  
  28. #if (__GNUC__==2) && (__GNUC_MINOR__>=7)
  29. #define va_start(AP, LASTARG) (AP = ((__gnuc_va_list)\
  30.                      __builtin_next_arg (LASTARG)))
  31. #else
  32. #define va_start(AP, LASTARG) (AP = ((__gnuc_va_list)\
  33.                      __builtin_next_arg ()))
  34. #endif
  35.  
  36. #define va_end(AP)
  37.  
  38. /* We cast to void * and then to TYPE * because this avoids
  39.    a warning about increasing the alignment requirement.  */
  40. #define va_arg(AP, TYPE)                                                \
  41.  (AP = (__gnuc_va_list) ((char *) (AP) + __va_rounded_size (TYPE)),    \
  42.   *((TYPE *) (void *) ((char *) (AP) - ((sizeof (TYPE) < sizeof (int)    \
  43.                      ? sizeof (TYPE)        \
  44.                      : __va_rounded_size (TYPE))))))
  45.  
  46. #ifndef _VA_LIST_
  47. #define _VA_LIST_
  48. typedef __gnuc_va_list va_list;
  49. #endif /* _VA_LIST_ */
  50.  
  51. #else
  52.  
  53. typedef    __VA_LIST__ va_list;
  54.  
  55. # ifdef __TURBOC__
  56. #  define va_start(list, param)   ((list) = ...)
  57. #  define va_arg(list, type)      (*((type *) (list))++)
  58. #  define va_end(list)
  59. # else
  60. #  define va_start(list,param)  list = ((va_list) &(param)) \
  61.                    + ((sizeof(param) + 1) & ~1)
  62. #  define va_arg(list,type)     ((type *)(list += ((sizeof(type) + 1) & ~1)))[-1]
  63. #  define va_end(list)
  64. # endif /* __TURBOC__ */
  65.  
  66. #endif /* __GNUC__ */
  67.  
  68. #endif /* va_start */
  69.  
  70. #endif /* _STDARG_H */
  71.